/* ARexx Web Server Version 2.0 */ if ~show('L','rexxsupport.library') then addlib('rexxsupport.library',0,-30,0) path="amitcp:www" /* No trailing "/"!! */ pull a file=subword(a,2,1) if right(file,1)="/" then file=file"index.html" if index(upper(file),".CGI")~=0 then signal cgi if exists(path||file)=0 then bad=1 if index(file,"//")~=0 then signal error if index(file,":")~=0 then signal error ext=upper(substr(file,lastpos(".",file),length(file))) mime="text/html" if ext=".HTML"|ext=".HTM"|ext=".HML" then mime="text/html" if ext=".DOC"|ext=".TXT" then mime="text/plain" if ext=".GUIDE" then mime="text/aguide" if ext=".GIF" then mime="image/gif" if ext=".JPG"|ext=".JPEG" then mime="image/jpeg" if ext=".WAV"|ext=".AU"|ext=".8SVX" then mime="audio/*" if ext=".MID"|ext=".MIDI" then mime="audio/x-midi" if ext=".LHA"|ext=".LZH"|ext=".LZX" then mime="application/octet-stream" if ext=".MOCHA" then mime="language/mocha" if ext=".GSM"|ext=".GSD" then mime="audio/x-gsm" if ext=".PS" then mime="application/postscript" say "HTTP/1.0 200 OK" say "Server: ARexxWebServer/2.0" say "Date: "||date()||" "||time() say "Author: Casey Halverson (cmdo@gte.net)" say "Accept-ranges: bytes" say "Content-length: "||subword(statef(path||file),2,1) say "Content-type: "||mime if bad=1 then signal bad say "" if mime~="text/html" then signal binary call open(1,path||file,'r') do until eof(1)=1 a=readln(1) if index(a,"'stuff say null address command "rx "||path||"/cgi-bin/"||rexx say stuff a="" return binary: address command 'c:copy "'||path||file||'" CONSOLE:' exit bad: say "HTTP/1.0 404 Not Found" say "Content-Type: text/html" say "" say "

ERROR

ARexxWebServer error 404:
Page does not exist
FILENAME: "||file||"" exit error: say "HTTP/1.0 400 Forbidden" say "Content-Type: text/html" say "" say "

ERROR

ARexxWebServer error 400:
You may not place : or double //'s in a URL
FILENAME: "||file||"" exit